package com.iweb.newa202104.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * description:  <br>
 * date: 2021/5/13 17:25 <br>
 * author: ztz <br>
 * version: 1.0 <br>
 * @author Tansty
 */
@Slf4j
@WebFilter(urlPatterns = "/resource/*", filterName = "ResourceFilter")
public class ResourceFilter implements Filter {
    private final String[] EXCLUDE_URL = {"/getResourceByCategory"};
    private final int PRE_URL_LENGTH = "/resource".length();
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        FilterUtil.commonFilter(servletRequest, servletResponse, filterChain, PRE_URL_LENGTH, EXCLUDE_URL);
    }

    @Override
    public void destroy() {

    }
}
